﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WEALTH
{
    public partial class Risk : System.Web.UI.Page
    {
        ExcuteDao dao = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.btnSubmit.ServerClick += new ImageClickEventHandler(btnSubmit_ServerClick);
            if (!IsPostBack)
            {
                loaderData();
            }
        }

        void btnSubmit_ServerClick(object sender, ImageClickEventArgs e)
        {
            int csCount = 0;
            for (int i = 1; i <= 12; i++)
            {
                csCount += int.Parse(Request.Form["select" + i.ToString()].ToString());
            }

            string resultText = "保守型";

            if (csCount < int.Parse(bs.Value))
            {
                resultText = "保守型";
            }
            else if (csCount > int.Parse(bs.Value) && csCount < int.Parse(wj.Value))
            {
                resultText = "稳健型";
            }
            else if (csCount > int.Parse(wj.Value) && csCount < int.Parse(cz.Value))
            {
                resultText = "成长型";
            }
            else if (csCount > int.Parse(cz.Value) && csCount < int.Parse(jq.Value))
            {
                resultText = "进取型";
            }
            else if (csCount > int.Parse(jq.Value) && csCount < int.Parse(jj.Value))
            {
                resultText = "激进型";
            }

            Server.Transfer("RiskResult.aspx?resultText=" + resultText + "&csCount=" + csCount);
        }

        //=============================================
        //函数名称:loaderData()
        //作    用:将查询到的内容绑定到控件上
        //=============================================
        private void loaderData()
        {
            DataTable dt1 = dao.GET_CsSetting();

            if (dt1 != null && dt1.Rows.Count > 0)
            {
                bs.Value = dt1.Rows[0]["csBsValue"].ToString();
                wj.Value = dt1.Rows[0]["csWjValue"].ToString();
                cz.Value = dt1.Rows[0]["csCzValue"].ToString();
                jq.Value = dt1.Rows[0]["csJqValue"].ToString();
                jj.Value = dt1.Rows[0]["csJjValue"].ToString();
            }
        }

        public void btnSubmit_Click(Object sender, CommandEventArgs e)//自己编写的按钮点击事件
        {
        }

    }
}